package com.oceansoft.mobile.econsole.modules.api.controller;

import com.oceansoft.mobile.econsole.modules.api.entity.SubNews;
import com.oceansoft.mobile.econsole.modules.api.service.ISubService;
import com.oceansoft.mobile.econsole.modules.base.controller.BaseController;
import com.oceansoft.mobile.econsole.modules.base.entity.Result;
import org.apache.log4j.Logger;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * ClassName: ApiSubController
 * Desc: 订阅接口
 * Date： 2016/10/27
 * Created：shaom
 */
@Controller
@RequestMapping("api/sub")
public class ApiSubController extends BaseController {

    @Resource
    private ISubService subService;

    /**
     * 获取订阅推动号(极光推送tag)，从APP获取
     *
     * @return
     */
    @Deprecated
    @ResponseBody
    @RequestMapping("sendCode/{code}")
    public Result sendCode(@PathVariable("code") String code) {
        return subService.saveCode(code);
    }

    /**
     * 获取订阅的新闻(从大厅获取)
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "push", consumes = {MediaType.APPLICATION_JSON_VALUE})
    public Result subNews(@RequestBody SubNews news) {
        return subService.subNews(news);
    }

}
